from django.contrib import admin
from teacher.models import TeacherModel
from teacher.models import TeacherCar
from teacher.models import TeacherInvite
from teacher.models import TeacherInviteCar
from teacher.models import TeacherInvitePerson
from teacher.models import TeacherInviteVerify
from teacher.models import TeacherPerson

@admin.register(TeacherModel)
class TeacherModelAdmin(admin.ModelAdmin):
    list_display = ("dept", "name", "phone", "is_security", "is_leader", "is_admin")
    list_filter = ("dept", "is_security", "is_leader", "is_admin")
    search_fields = ("name", "phone")
    autocomplete_fields = []


@admin.register(TeacherPerson)
class TeacherPersonAdmin(admin.ModelAdmin):
    list_display = ("teacher", "person", "updated")
    list_filter = ()
    search_fields = ("teacher__name", "teacher__phone")
    autocomplete_fields = ["teacher", "person"]


@admin.register(TeacherCar)
class TeacherCarAdmin(admin.ModelAdmin):
    list_display = ("teacher", "car", "updated")
    list_filter = ()
    search_fields = ("teacher__name", "teacher__phone")
    autocomplete_fields = ["teacher", "car"]


@admin.register(TeacherInvite)
class TeacherInviteAdmin(admin.ModelAdmin):
    list_display = ("teacher",  "person", "status", "when", "isfree")
    list_filter = ("status",)
    search_fields = ("visitor__name", "visitor__phone")
    autocomplete_fields = ["teacher",]


@admin.register(TeacherInvitePerson)
class TeacherInvitePersonAdmin(admin.ModelAdmin):
    list_display = ("invite", "person")
    list_filter = ("invite",)
    search_fields = ("person__name", "person__phone")
    autocomplete_fields = ["invite","person",]


@admin.register(TeacherInviteCar)
class TeacherInviteCarAdmin(admin.ModelAdmin):
    list_display = ("invite", "car")
    list_filter = ("invite",)
    search_fields = ("car__plate",)
    autocomplete_fields = ["invite","car",]


@admin.register(TeacherInviteVerify)
class TeacherInviteVerifyAdmin(admin.ModelAdmin):
    list_display = ("invite","stage","status",)
    list_filter = ("stage","status",)
    autocomplete_fields = ["invite",]
